package org.bspv.pharma.web.bean;

import java.util.Collections;
import java.util.List;

/**
 * 
 * @author guillaume
 *
 */
public class StockStatus implements Comparable<StockStatus>{
	
	private Short value;
	private String name;
	

	public StockStatus(Short value, String name) {
		super();
		this.value = value;
		this.name = name;
	}

	/**
	 * @return the value
	 */
	public Short getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(Short value) {
		this.value = value;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	public int compareTo(StockStatus st) {
		int res;
		if(st == null) {
			res = -1;
		} else {
			res = this.value.compareTo(st.value);
		}
		return res;
	}
	/**
	 * Renvoie le plus faible de la liste
	 * @param lstStockStatus
	 * @return
	 */
	public static StockStatus min(List<StockStatus> lstStockStatus) {
		StockStatus st = null;
		if (lstStockStatus != null && lstStockStatus.size() > 0) {
			if (lstStockStatus.size() > 1) {
				//tri croissant
				Collections.sort(lstStockStatus);
			}
			st = lstStockStatus.get(0);
		}
		return st;
	}
	
}
